package edu.hadassah.prettyprint.doc.xml;

import java.util.ArrayList;
import java.util.List;

import edu.hadassah.prettyprint.doc.ContentElement;
import edu.hadassah.prettyprint.doc.IVisitor;

public class Tag extends ContentElementImpl{
	
	private final String name;
	private final List<Attribute> attributes;
	private final List<ContentElement> content;
	
	public Tag(ContentElement parent, String name) {
		super(parent);
		this.name = name;
		this.attributes = new ArrayList<Attribute>();
		this.content = new ArrayList<ContentElement>();
	}
	
	public void addChild(ContentElement child) {
			this.content.add(child);
	}
	
	public void addAttribute(Attribute child) {
			this.attributes.add(child);
	}

	public String getName() {
		return name;
	}

	public List<Attribute> getAttributes() {
		return attributes;
	}

	public List<ContentElement> getContent() {
		return content;
	}
	
	public void accept(IVisitor visitor) {
		visitor.visit(this);
		for (Attribute attribute : this.getAttributes()) {
			attribute.accept(visitor);
		}

		for (ContentElement element : this.getContent()) {
			element.accept(visitor);
		}
//		visitor.printEnd(this);
    }


}
